package in.muton.edushare.components.messaging.api;

import in.muton.edushare.EduShareSession;
import in.muton.edushare.auth.api.Authentication;

import com.edushare.common.dao.OutgoingEmailsDAO;
import com.edushare.common.mailer.NewPoll;
import com.edushare.common.vo.Poll;
import com.edushare.common.vo.Users;

public class PollMessage extends Message{
	public PollMessage(Poll poll){
		this.p = poll;
	}
	
	@Override
	protected void addditionalProcessing(Users u) {
		Users loggedIn = EduShareSession.get().getLoggedInUser();
		Authentication auth= new Authentication(u, EduShareSession.get().getLoggedInUser());
		if(!auth.getSetting(Authentication.NOTIFY_POL).equals("t") || u==loggedIn)
			return;

		new OutgoingEmailsDAO(EduShareSession.get()
				.getSessionORMInterface()).sendMail(new NewPoll(
				EduShareSession.get().getLoggedInUser(), u, p).send());
	}

	@Override
	protected String getMessage() {
		return "<<<EDUSHAREMESSAGINGMETADATA:POLL:"
		+ p.getPollId() + ">>>";
	}

	private Poll p = null;
}
